#include "gofgame/common/resource/HornedTextureBrushResource.h"

using namespace gofgame::common::resource;

HornedTextureBrushResource::HornedTextureBrushResource(
	int cornerWidth,
	int cornerHeight,
	const char *imageName,
	Brush *baseBrush) 
	: cornerSize(cornerWidth, cornerHeight) {
	this->imageName = imageName;
	if (!baseBrush) {
		baseBrush = Brush::white();
	}
	this->baseBrush = baseBrush;
}

void HornedTextureBrushResource::onCollectFileNames(FileNameCollector &fnc) {
	fnc.collect(this->imageName);
}

void HornedTextureBrushResource::onLoad() {
	Ref<CCTexture2D> tex = CCTextureCache::sharedTextureCache()->addImage(this->imageName.c_str());
	this->value.initialize(new HornedTextureBrush(this->cornerSize, tex, this->baseBrush));
}
